package net.wanho.controller;

import lombok.extern.slf4j.Slf4j;
import net.wanho.util.MyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Author：汤小洋
 * Date：2025-09-15 9:33
 * Description：<描述>
 */
@Slf4j
@RestController
// @CrossOrigin
public class HelloController {

    @Autowired
    private Date date;

    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        MyUtil.print();

        log.info("执行了hello方法。。。。。。。");

        try {
            int a = 1/0;
        } catch (Exception e){
            log.error("出现异常啦：" + e.getMessage());
        }

        return "Hello World";
    }

    @RequestMapping("/param1")
    @ResponseBody
    public String param1(String username, String password){
        return "username:" + username + "  password:" + password;
    }

    @RequestMapping("/hello2")
    public Date hello2(){
        return date;
    }


}
